package cn.tedu.tw.wyy.jdbc;

import java.sql.*;

import org.gjt.mm.mysql.Driver;

import static java.sql.DriverManager.getConnection;

public class AppJdbcSelect {
    public static void main(String[] args) throws Exception {
        Class.forName("com.mysql.jdbc.Driver");
        String url = "jdbc:mysql://localhost:3306/test?useSSL=false";
        String username = "root";
        String password = "root";
        Connection connection = getConnection(url, username, password);
        Statement statement = connection.createStatement();
        String sql = "SELECT `id`,`username`,`password`FROM `user`";
        ResultSet set = statement.executeQuery(sql);


        while (set.next()) {
            String v = set.getString(1);
            Long id = set.getLong(1);
            System.out.println("id is: " + id + ", username is : " + v);


        }

    }
}
